/**
 * @param {number[]} nums
 * @return {number[]}
 */
var numberOfPairs = function (nums) {
  let stackList = [];

  let num = 0;

  nums.forEach((e) => {
    if (!stackList.length) {
      stackList.push(e);
    } else {
      let _index = stackList.indexOf(e);
      if (_index != -1) {
        stackList.splice(_index, 1);

        // stackList = stackList.filter((_e, index) => index != _index);
        num++;
      } else {
        stackList.push(e);
      }
    }
  });

  return [num, stackList.length];
};

console.log(numberOfPairs([1, 2, 0, 0]));
